<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  header("location:checklogin.php");
}

$loadingInvoiceId = 0;
$truckId          = 0;
$toId             = 0;
$invoiceDate      = 0;

$selectLoadInvoice = "SELECT loadingInvoiceId,truckId,toId,invoiceDate,invoiceNo,fromId,branch.branchName
                        FROM loadinginvoice
                        JOIN branch ON branch.branchId = loadinginvoice.toId
                       WHERE fromId = ".$_REQUEST['fromId']."
                         AND invoiceNo = ".$_REQUEST['invoiceNo']."";
$selectLoadInvoiceRes = mysql_query($selectLoadInvoice);
while($loadRow = mysql_fetch_array($selectLoadInvoiceRes))
{
	$loadingInvoiceId = $loadRow['loadingInvoiceId'];
	$truckId          = $loadRow['truckId'];
	$toId             = $loadRow['branchName'];
	$invoiceDate      = $loadRow['invoiceDate'];
}

$t=0;
$loadInvoiceArray = array();
$selectLoadInvoice = "SELECT loadingInvoiceId,lrNo,consignor,consignee,weight,discription,toPay,octroi,octroiNo
                        FROM loadinginvoicedetail
                       WHERE loadingInvoiceId = ".$loadingInvoiceId."";
$selectLoadInvoiceRes = mysql_query($selectLoadInvoice);
if($selectLoadInvoiceRes != "")
{
  while($loadInvoiceRow = mysql_fetch_array($selectLoadInvoiceRes))
  {
  $loadInvoiceArray[$t]['loadingInvoiceId'] = $loadInvoiceRow['loadingInvoiceId'];
  	$loadInvoiceArray[$t]['lrNo']           = $loadInvoiceRow['lrNo'];
  	$loadInvoiceArray[$t]['consignor']      = $loadInvoiceRow['consignor'];
  	$loadInvoiceArray[$t]['consignee']      = $loadInvoiceRow['consignee'];
  	$loadInvoiceArray[$t]['weight']         = $loadInvoiceRow['weight'];
  	$loadInvoiceArray[$t]['discription']    = $loadInvoiceRow['discription'];
  	$loadInvoiceArray[$t]['toPay']          = $loadInvoiceRow['toPay'];
  	$loadInvoiceArray[$t]['octroi']         = $loadInvoiceRow['octroi'];
  	$loadInvoiceArray[$t]['octroiNo']       = $loadInvoiceRow['octroiNo'];
  	$t++;
  }
}
include("./bottom.php");
$smarty->assign("loadInvoiceArray",$loadInvoiceArray);
$smarty->assign("truckId",$truckId);
$smarty->assign("toId",$toId);
$smarty->assign("invoiceDate",$invoiceDate);
$smarty->display('setLodingCashMemo.tpl');
?>